//
//  OfficeLeaveListVC.swift
//  EduManage
//
//  Created by design02 on 16/12/19.
//  Copyright © 2016年 wsl. All rights reserved.
//

import UIKit

class OfficeLeaveListVC: BaseViewController, UITableViewDelegate, UITableViewDataSource {

    var leaverArray: [JSON]!
    var navTitle: String!
    
    var tableView: UITableView!
    
    override func viewDidLoad() {
        super.viewDidLoad()

        self.title = navTitle
        setupViews()

    }

    
    func setupViews(){

        tableView = UITableView.init(frame: self.view.frame)
        tableView.backgroundColor = UIColor.init(hexString: "f6f6f6", alpha: 1)
        tableView.delegate = self
        tableView.dataSource = self
        tableView.separatorStyle = UITableViewCellSeparatorStyle.none
        self.view.addSubview(tableView)

    }
    
    //MARK: - ui table view delegate data source 
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return leaverArray.count
    }
    
    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        let cellIdentifier = "officeLeaveListCellIdentifier";
        
        let dic = leaverArray[indexPath.row] 
        
        let cell: OfficeLeaveListCell = OfficeLeaveListCell(dictionary: dic, reuseIdentifier: cellIdentifier)
        
        cell.selectionStyle = UITableViewCellSelectionStyle.none;
        cell.accessoryType = UITableViewCellAccessoryType.none
        
        cell.nameLabel.text = "请假人 " + navTitle
        
        return cell
  
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        
        let dic = leaverArray[indexPath.row]

        let leaverDetailVC = OfficeLeaveDetilVC()
        leaverDetailVC.dic = dic
        leaverDetailVC.navTitle = self.navTitle
        self.navigationController?.pushViewController(leaverDetailVC, animated: true)
        
    }
    
    func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        return 130
    }
    
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
